Skip to content

Conversation

vrana
Copy link
Contributor

@vrana vrana commented Sep 11, 2025

There are other cases where this rule is harmful, I show them in tests.

Doc: phpstan/phpstan#13489

@ondrejmirtes
Copy link
Member

Hi, I've said in the past that reportAlwaysTrueInLastCondition has been added for completeness and to match how PHPStan behaved by default in the past, but personally I think no one should use it.

What's your reason to enable it? Where do you see the benefit?

@vrana
Copy link
Contributor Author

vrana commented Sep 11, 2025

The example from the test seems reasonable to me:

	public function doFoo(int $i, \stdClass $std)
	{
		if ($i) {
		} elseif ($std) { // error only with reportAlwaysTrueInLastCondition
		}
	}

@ondrejmirtes ondrejmirtes merged commit 9c6cabc into phpstan:2.1.x Sep 12, 2025
446 of 457 checks passed
@ondrejmirtes
Copy link
Member

Thank you.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants